package com.bobo.demo.Thread;

//模拟网络延时：放大问题的发生性
public class TestSleep implements Runnable {
        //票数
        private int tickNums = 10;

        @Override
        public void run() {

            while(true) {
                if (tickNums <= 0) {
                    break;
                }
                //模拟延时
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName()+"-->拿到了第"+tickNums--+"-票");
            }

        }

        public static void main(String[] args) {
            com.bobo.demo.Thread.TestRunnable2 t1 = new com.bobo.demo.Thread.TestRunnable2();
            //创建线程对象，通过线程对象来开启我们的现场，代理

            new Thread(t1,"苏苏").start();
            new Thread(t1,"波波").start();
            new Thread(t1,"黄牛党").start();

        }

}
